package com.itboye.shop.me.qianbao;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Bundle;
import android.view.Gravity;
import android.view.View;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.itboye.shop.R;
import com.itboye.shop.app.MyApplication;
import com.itboye.shop.base.BaseActivity;
import com.itboye.shop.util.loadutil.IsUtilUid;
import com.itboye.shop.util.loadutil.MAlert;

/**
 * 支付密码
 */
public class ZhiFuPassActivity extends BaseActivity {
    TextView tvTitle;
    ImageView back;
    RelativeLayout zhifu_shezhi, zhifu_chongzhi;
    String pwdpay;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_zhi_fu_pass);

        tvTitle.setText("设置支付密码");
        pwdpay= IsUtilUid.isPwd();
        //支付密码修改成功的广播
        IntentFilter intentFilterExit = new IntentFilter(JiDePassTwoActivity.ZHI_FU_PASS_OK);
        registerReceiver(xiugaiPassBroadcastReceiver, intentFilterExit);
    }
    BroadcastReceiver xiugaiPassBroadcastReceiver = new BroadcastReceiver() {
        public void onReceive(Context context, Intent intent) {
            finish();
        };
    };

    @Override
    protected void onDestroy() {
        super.onDestroy();
        unregisterReceiver(xiugaiPassBroadcastReceiver);
    }
    @Override
    public void onClick(View view) {
        Intent intent = null;
        switch (view.getId()) {
            case R.id.back:
                finish();
                break;
            case R.id.zhifu_shezhi:// 设置支付密码
                onPwdApplcation(pwdpay);

                break;
            case R.id.zhifu_chongzhi:// 重置支付密码
                intent = new Intent(this, ZhiFuPassChongZhiActivity.class);
                startActivity(intent);
                break;
            default:
                break;
        }
    }
    public void onPwdApplcation(String pwd) {
        if (pwd == null || pwd == "") {
            Intent intent = new Intent(MyApplication.instatnce, ZhiFuPassSheZhiActivity.class);
            startActivity(intent);
            finish();
        }else{
            MAlert.alert("支付密码已设置", Gravity.CENTER);
        }
    }
}
